<template>
	<view :class="classList" :style="customStyleComp" @click.stop="" @tap.stop="">
		<view class="MyDialog-content" :style="contentStyle">
			<slot></slot>
		</view>
	</view>
</template>

<script>
	import {
		tools
	} from '@/utils/util';
	export default {
		name: "MyDialog",
		props: {
			customStyle: {
				type: Object,
				default () {
					return {}
				}
			},
			show: {
				type: Boolean,
				default: false
			},
			height: {
				type: Number,
				default: 0
			},
			bottom:{
				type:Number,
				default:0,
			},
			zIndex:{
				type:Number,
				default:0,
			},
		},
		data() {
			return {
				customStyleComp: {

				},
				contentStyle: {},
				classList: ['MyDialog']
			};
		},
		created() {
			this.initCustomStyleComp();
		},
		methods: {
			initCustomStyleComp(customStyle) { //组件样式初始化
				customStyle = customStyle || this.customStyle;
				let customStyleComp = {
					...this.customStyleComp,
					...customStyle
				};
				this.customStyleComp = customStyleComp;
				// this.contentStyle.height = this.height + 'vh';
			},
			showComp() { //显示组件
				// this.customStyleComp.height = ((this.height) ?? 100) + 'vh';
				this.customStyleComp.height = `calc(${(this.height) ?? 100}vh + 0vw)`;
				this.customStyleComp.bottom = `calc(${(this.bottom) ?? 0}vw + 0vw)`;
				this.customStyleComp.zIndex = `${this.zIndex??100}`;
				this.classList = [...this.classList, 'show'];
				this.contentStyle.height = this.height + 'vh';
			},
			hideComp() { //隐藏组件
				this.customStyleComp.height = 0 + 'vh';
				this.classList = ['MyDialog'];
			}
		},
		watch: {
			customStyle: {
				handler(val) {
					this.initCustomStyleComp();
				},
				immediate: true,
				deep: true
			},
			show: {
				handler(val) {
					val ? this.showComp() : this.hideComp();
				},
			}
		},
		computed: {}
	}
</script>

<style lang="scss">
	.MyDialog {
		overflow: hidden;
		width: 100vw;
		height: 0vh;
		position: absolute;
		border-radius: 5vw 5vw 0vw 0vw;
		background: linear-gradient(180deg, rgba(36, 67, 67, 1) 0%, rgba(34, 37, 43, 1) 100%);
		// background: #0e1c18;
		transition: all 300ms;
		
		// bottom: 15vw;
		// bottom: 0vw;
		&.show {
			// border-top: 2px solid rgb(115, 253, 230);
		}

		.MyDialog-content {
			display: flex;
			flex-direction: column;
			overflow: auto;
		}
	}
</style>